/*
* jiyan1
*/
package com.jiyan.errorcode.ctrl;

import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;
import java.util.List;
import java.util.HashMap;

import com.jiyan.core.entity.BeanRet;
import com.jiyan.core.entity.Page;
import com.jiyan.core.tools.redis.RedisUtils;
import com.jiyan.errorcode.entity.ErrorcodeLocal;
import com.jiyan.errorcode.service.ErrorcodeLocalSV;

/**
* 错误码本地化，将对应国际化进行配置 控制器
*
* @author jiyan
*/
@RestController
@RequestMapping("/errorcodeLocal")
@Slf4j
@Api(value = "错误码本地化，将对应国际化进行配置控制器", description = "错误码本地化，将对应国际化进行配置控制器")
public class ErrorcodeLocalCtrl {

    @Resource
    protected RedisUtils redisUtils;

    @Resource
    private ErrorcodeLocalSV errorcodeLocalSV;

    /**
    * 查询ErrorcodeLocal一个详情信息
    * @param id 
    * @param code 编码
    * @return BeanRet
    */
    @ApiOperation(value = "查询ErrorcodeLocal一个详情信息", notes = "查询ErrorcodeLocal一个详情信息")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "",dataType = "java.lang.Long", paramType = "query"),
        @ApiImplicitParam(name = "code", value = "编码",dataType = "java.lang.String", paramType = "query")
    })
    @GetMapping(value = "/load")
    @ResponseBody
    public ErrorcodeLocal load(java.lang.Long id,java.lang.String code) {
        if(id==null){
        return null;
        }
        if(code==null){
        return null;
        }
        ErrorcodeLocal errorcodeLocal = errorcodeLocalSV.load(id,code);
        log.info(JSON.toJSONString(errorcodeLocal));
        return errorcodeLocal;
    }


    /**
    * 根据条件id查询ErrorcodeLocal一个详情信息
    *
    * @param id 
    * @return BeanRet
    */
    @ApiOperation(value = "查询ErrorcodeLocal一个详情信息", notes = "查询ErrorcodeLocal一个详情信息")
    @ApiImplicitParams({
       @ApiImplicitParam(name = "id", value = "",dataType = "java.lang.Long", paramType = "path")
    })
    @GetMapping(value = "/load/id/{id}")
    @ResponseBody
    public ErrorcodeLocal loadById(@PathVariable java.lang.Long id) {
        if(id==null){
           return null;
        }
        ErrorcodeLocal errorcodeLocal = errorcodeLocalSV.loadById(id);
        log.info(JSON.toJSONString(errorcodeLocal));
        return errorcodeLocal;
    }
    /**
    * 根据条件code查询ErrorcodeLocal一个详情信息
    *
    * @param code 编码
    * @return BeanRet
    */
    @ApiOperation(value = "查询ErrorcodeLocal一个详情信息", notes = "查询ErrorcodeLocal一个详情信息")
    @ApiImplicitParams({
       @ApiImplicitParam(name = "code", value = "编码",dataType = "java.lang.String", paramType = "path")
    })
    @GetMapping(value = "/load/code/{code}")
    @ResponseBody
    public ErrorcodeLocal loadByCode(@PathVariable java.lang.String code) {
        if(code==null){
           return null;
        }
        ErrorcodeLocal errorcodeLocal = errorcodeLocalSV.loadByCode(code);
        log.info(JSON.toJSONString(errorcodeLocal));
        return errorcodeLocal;
    }


    /**
    * 查询ErrorcodeLocal信息集合
    *
    * @return 分页对象
    */
    @ApiOperation(value = "查询ErrorcodeLocal信息集合", notes = "查询ErrorcodeLocal信息集合")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "curPage", value = "当前页", required = true, paramType = "query"),
    @ApiImplicitParam(name = "pageSize", value = "分页大小", required = true, paramType = "query"),
    })
    @PostMapping(value = "/list")
    @ResponseBody
    public List<ErrorcodeLocal> list(@RequestBody @ApiIgnore ErrorcodeLocal errorcodeLocal,Integer curPage,Integer pageSize) {
        Page<ErrorcodeLocal> page=new Page<ErrorcodeLocal>(pageSize,curPage);
        List<ErrorcodeLocal> errorcodeLocals = errorcodeLocalSV.list(errorcodeLocal,page.genRowStart(),page.getPageSize());
        int total = errorcodeLocalSV.count(errorcodeLocal);
        page.setTotalRow(total);
        log.info(JSON.toJSONString(page));
        return errorcodeLocals;
    }


    /**
    * 查询ErrorcodeLocal信息集合
    *
    * @return 分页对象
    */
    @ApiOperation(value = "查询ErrorcodeLocal信息集合", notes = "查询ErrorcodeLocal信息集合")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "curPage", value = "当前页", required = true, paramType = "query"),
    @ApiImplicitParam(name = "pageSize", value = "分页大小", required = true, paramType = "query"),
    @ApiImplicitParam(name = "id", value = "", paramType = "query"),
    @ApiImplicitParam(name = "code", value = "编码", paramType = "query")
    })
    @GetMapping(value = "/list/by")
    @ResponseBody
    public List<ErrorcodeLocal> listByPk(java.lang.Long id,java.lang.String code,Integer curPage,Integer pageSize) {
        Page<ErrorcodeLocal> page=new Page<ErrorcodeLocal>(pageSize,curPage);
        List<ErrorcodeLocal> errorcodeLocals = errorcodeLocalSV.list(id,code, page.genRowStart(),page.getPageSize());
        int total = errorcodeLocalSV.count(id,code);
        page.setTotalRow(total);
        log.info(JSON.toJSONString(page));
        return errorcodeLocals;
    }

    /**
    * 统计ErrorcodeLocal信息数量根据主键
    *
    * @return 总条数
    */
    @ApiOperation(value = " 统计ErrorcodeLocal信息数量根据主键", notes = " 统计ErrorcodeLocal信息数量根据主键")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "id", value = "", paramType = "query"),
    @ApiImplicitParam(name = "code", value = "编码", paramType = "query")
    })
    @GetMapping(value = "/count/by")
    @ResponseBody
    public Integer count(java.lang.Long id,java.lang.String code) {
        return errorcodeLocalSV.count(id,code);
    }

    /**
    * 统计ErrorcodeLocal信息数量
    *
    * @return 总条数
    */
    @ApiOperation(value = "统计ErrorcodeLocal信息数量", notes = "统计ErrorcodeLocal信息数量")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "id", value = "", paramType = "query"),
    @ApiImplicitParam(name = "code", value = "编码", paramType = "query"),
    @ApiImplicitParam(name = "errorCode", value = "错误码", paramType = "query"),
    @ApiImplicitParam(name = "language", value = "语言 如 英语，普通话，法语等", paramType = "query"),
    @ApiImplicitParam(name = "info", value = "文本对照 ", paramType = "query")
    })
    @PostMapping(value = "/count")
    @ResponseBody
    public Integer count(@RequestBody ErrorcodeLocal errorcodeLocal) {
        return errorcodeLocalSV.count(errorcodeLocal);
    }



    /**
    * 创建ErrorcodeLocal
    *
    * @return BeanRet
    */
    @ApiOperation(value = "创建ErrorcodeLocal", notes = "创建ErrorcodeLocal")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "errorCode", value = "错误码", paramType = "query"),
        @ApiImplicitParam(name = "language", value = "语言 如 英语，普通话，法语等", paramType = "query"),
        @ApiImplicitParam(name = "info", value = "文本对照 ", paramType = "query")
    })
    @PostMapping("/build")
    @ResponseBody
    public ErrorcodeLocal build(@RequestBody @ApiIgnore ErrorcodeLocal errorcodeLocal) {
        errorcodeLocalSV.save(errorcodeLocal);
        return errorcodeLocal;
    }


    /**
    * 修改ErrorcodeLocal
    *
    * @return BeanRet
    */
    @ApiOperation(value = "修改ErrorcodeLocal", notes = "修改ErrorcodeLocal")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "", paramType = "query"),
        @ApiImplicitParam(name = "code", value = "编码", paramType = "query"),
        @ApiImplicitParam(name = "errorCode", value = "错误码", paramType = "query"),
        @ApiImplicitParam(name = "language", value = "语言 如 英语，普通话，法语等", paramType = "query"),
        @ApiImplicitParam(name = "info", value = "文本对照 ", paramType = "query")
    })
    @PutMapping("/modify")
    @ResponseBody
    public ErrorcodeLocal modify(@RequestBody @ApiIgnore ErrorcodeLocal errorcodeLocal) {
        errorcodeLocalSV.modify(errorcodeLocal);
        return errorcodeLocal;
    }

    /**
    * 删除ErrorcodeLocal
    *
    * @return BeanRet
    */
    @ApiOperation(value = "删除ErrorcodeLocal", notes = "删除ErrorcodeLocal")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "", paramType = "query"),
        @ApiImplicitParam(name = "code", value = "编码", paramType = "query")
    })
    @DeleteMapping("/delete")
    @ResponseBody
    public BeanRet delete(java.lang.Long id,java.lang.String code) {
        errorcodeLocalSV.delete(id,code);
        return BeanRet.create(true, "删除ErrorcodeLocal成功");
    }

}
